
function doSearch() {
	$('#tt').datagrid('load', {
		isExec : $('#isExec').combobox('getValue'),
		sysver : $('#sysVer').combobox('getValue')
	});
	$('#tt').datagrid('unselectAll');
}

$(function() {
	$('#isExec').combobox("select",-1);
});

function add() {
	showMyWindow('定时器', '/taskverTimer/add', 800, 500);
}

function edit() {
	var row = $('#tt').datagrid('getSelected');
	if (row) {
		showMyWindow('定时器', '/taskverTimer/' + row.id + '/update', 700, 500);
	} else {
		showMsg(market.content.title, market.content.tips, alert);
	}
}

function del() {
	var row = $('#tt').datagrid('getSelected');
	$.messager.confirm('温馨提醒', '你确定删除本条数据吗？', function(r) {
		if (r) {
			$.get('/taskverTimer/del?id=' + row.id, function(data) {
				if (data.return_code == '1') {
					top.showMsg(market.content.title, data.return_msg, alert);
					doSearch();
				} else if (data.return_code == '3') {
					top.showMsg(market.content.title, data.return_msg, alert);
				} else {
					$.messager.alert(market.content.title, data.return_msg);
				}
			});
		}
	});
}

function formatterIsExec(value) {
	if (value == 1) {
		return "已执行";
	}
	if (value == 0) {
		return "未执行";
	}
}

function formatterTaskType(value) {
	if (value == 1) {
		return "新增";
	}
	if (value == 2) {
		return "留存";
	}

}

function formatterStatus(value) {
	if (value == 1) {
		return "启用";
	}
	if (value == 0) {
		return "作废";
	}

}

function subEdit() {

	$('#ff').form(
		'submit',
		{
			url : '/taskverTimer/update',
			onSubmit : function() {
				return $(this).form('enableValidation').form('validate');
			},
			success : function(data) {
				showProcess(false);
				var data = eval('(' + data + ')');
				if (data.return_code == '1') {
					top.showMsg(market.content.title, data.return_msg, alert);
					if (parent !== undefined) {
						if ($.isFunction(parent.reloadParent)) {
							parent.reloadParent.call();
							parent.closeMyWindow();
						} else {
							parent.$("#tt").datagrid('reload');
							parent.closeMyWindow();
						}
					}
				}else if(data.return_code == '10'){
					$.messager.alert(market.content.title, data.return_msg);
					if (parent !== undefined) {
						if ($.isFunction(parent.reloadParent)) {
							parent.reloadParent.call();
							parent.closeMyWindow();
						} else {
							parent.$("#tt").datagrid('reload');
							parent.closeMyWindow();
						}
					}
				} else {
					$.messager.alert(market.content.title, data.return_msg);
				}
			},
			onLoadError : function() {
				showProcess(false);
				$.messager.alert(market.content.title, market.content.networkError);
			}
		});
}
